
import urllib.request
import random

url="http://www.ip138.com/"

iplist=['114.222.24.16:808','115.46.75.200:8123','115.46.78.178:8123']

# 初始化头部
proxy_support = urllib.request.ProxyHandler({"http":random.choice(iplist)})

# 创建一个 opener
opener = urllib.request.build_opener(proxy_support);

opener.addheaders=[("User-Agent","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36")]

# 安装 opener
urllib.request.install_opener(opener);

# 使用 opener
res = urllib.request.urlopen(url);




html = res.read().decode("utf-8");

print(html)
